"""
对象也可以作为形参来传递

"""

class People:
    def __init__(self, name):
        self.name = name
        self.xueliang = 100
    def shanghai(self, people, shanghai):  #对象也可以挡在参数来传递
        people.xueliang -= shanghai
        print(f"{self.name}对{people.name}造成了{shanghai}点伤害")
#警察类
class Hero(People):
    def showInfo(self):
        print(f"{self.name}的血量是{self.xueliang}")
    # def shanghai(self,people,shanghai=10): # p匪徒对象
    #     people.xueliang-=shanghai  #匪徒掉血
    #     print(f"{self.name}对{people.name}造成了{shanghai}点伤害")
#匪徒类
class Is(People):
    def showInfo(self):
        print(f"{self.name}的血量是{self.xueliang}")
    # def shanghai(self, people, shanghai=5):  # p警察对象
    #       people.xueliang -= shanghai  # 警察掉血
    #       print(f"{self.name}对{people.name}造成了{shanghai}点伤害")
h1 = Hero("警察")
h1.showInfo()
is1 = Is("匪徒")  # 名字跟血量
is1.showInfo()
while True:
    h1.shanghai(is1, 10)
    h1.showInfo()
    is1.shanghai(h1, 5)
    is1.showInfo()
    if h1.xueliang<=0:
        print(f"{is1.name}赢了")
        break
    elif is1.xueliang==0:
        print(f"{h1.name}赢了")
        break